//
//  GuaListViewController.swift
//  jiaoyi
//
//  Created by wjk on 2018/8/14.
//  Copyright © 2018年 wjk. All rights reserved.
//  挂牌交易进入专场

import UIKit
import SocketIO
import UIAlertController_Blocks
import JWTDecode
import SwiftyJSON
import BTNavigationDropdownMenu


class GuaListViewController: BaseViewController {
    
    var alert:UIAlertController?
    
    
    var server_time:Int?
    
    
    var manager:SocketManager?
    
    
    var sessionId:String = ""
    
    var type:Int = 0//0、竞价；1、挂牌；2、协商
    
    var fair_id:String!
    var type_name:String?
    var trade_type_text:String?
    var trade_date:String!
    var websocket:String!
    
    var section_ttl:Int?
    
    var timer:DispatchSourceTimer?
    var timer2:DispatchSourceTimer?
    
    let status:[String] = ["", "已启动", "等待", "交易中", "已结束", "休息中", "已结束", "专场即将结束", "已启动", "专场已关闭", "专场已暂停"]
    let status2:[String] = ["", "已启动", "等待", "交易中", "已暂停", "休息中", "已结束", "专场即将结束", "已启动", "已结束", "专场已关闭"]

    
    
    var header:GuaListHeaderView?
    
    private lazy var vcs :[UIViewController] = {
        
        if self.type == 0 {
        
        
        return [Bottom1ViewController().showType(t: 0).jiaoyiT(t: self.type).fair_id(f: self.fair_id),
                Bottom1ViewController().showType(t: 1).jiaoyiT(t: self.type).fair_id(f: self.fair_id),
                Bottom1ViewController().showType(t: 2).jiaoyiT(t: self.type).fair_id(f: self.fair_id),
                Bottom1ViewController().showType(t: 3).jiaoyiT(t: self.type).fair_id(f: self.fair_id),
                AmountDescViewController()]
        }else {
            return [Bottom1ViewController().showType(t: 0).jiaoyiT(t: self.type).fair_id(f: self.fair_id),
                    Bottom1ViewController().showType(t: 2).jiaoyiT(t: self.type).fair_id(f: self.fair_id),
                    AmountDescViewController()]
        }
    }()
    
    
    func showType(t:Int) -> GuaListViewController {
        self.type = t
        if t == 0 {
            self.title = "竞价交易"
        }else if t == 1 {
            self.title = "挂牌交易"
        }else if t == 2 {
            self.title = "协商交易"
        }
        return self
    }
    
    
    private lazy var titles : [String] = {
        if self.type == 0 {
            return ["交易中","当前竞价","本专场成交","标的清单","资金详情"]
        }else {
            return ["交易中","本专场成交","资金详情"]
        }
    }()
    
    private lazy var layout: LTLayout = {
        let layout = LTLayout()
        layout.isAverage = true
//        layout.sliderWidth = 80
        
        layout.lrMargin = 12
        layout.titleFont = UIFont.systemFont(ofSize: 12);
        layout.titleMargin = 10
        layout.titleViewBgColor = .white
        layout.bottomLineColor = baseColor()
        layout.titleColor = kRGBColorFromHex(rgbValue: 0x333333)
        layout.titleSelectColor = baseColor()
        return layout
    }()
    
    lazy var countView:CountDownTime = {
        let count = CountDownTime.CountDownView()
        return count
    }()
    
    private lazy var advancedManager: LTAdvancedManager = {
        
        let statusBarH = UIApplication.shared.statusBarFrame.size.height
        let Y: CGFloat = statusBarH + 44
        let H: CGFloat = glt_iphoneX ? (view.bounds.height - Y - 34) : view.bounds.height - Y
        let advancedManager = LTAdvancedManager(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: H), viewControllers: vcs, titles: titles, currentViewController: self, layout: layout, headerViewHandle: {
            self.header = testLabel()
            return self.header!
        })
        /* 设置代理 监听滚动 */
        advancedManager.delegate = self
        return advancedManager
    }()
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        manager?.defaultSocket.removeAllHandlers()
        manager?.defaultSocket.removeAllHandlers()
        self.countView.isHidden = true
    }
    
    
//    @objc func applicationWillResignActive(_ obj:NSNotification) {
//        print("监听是否触发home键挂起程序.")
//    }
    
    @objc func applicationDidBecomeActive(_ obj:NSNotification) {
        self.loadStatus()
    }
    
    override func viewWillAppear(_ animated: Bool) {
        
        super.viewWillAppear(animated)
        
//        NotificationCenter.default.addObserver(self, selector: #selector(self.applicationWillResignActive(_:)), name: NSNotification.Name.UIApplicationWillResignActive, object: nil)
        
        NotificationCenter.default.addObserver(self, selector: #selector(self.applicationDidBecomeActive(_:)), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil)
    }
    
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        
        
        
        
        manager?.defaultSocket.on("price", callback: { (data, ack) in
            let json = try? JSONSerialization.jsonObject(with: self.base64UrlDecode(data.first as! String) ?? Data(), options: [])
            
            print(jsonFormater(data: json as Any).description)
            
            self.loadStatus()
        })
        manager?.defaultSocket.on("target_status", callback: { (data, ack) in
            let json = try? JSONSerialization.jsonObject(with: self.base64UrlDecode(data.first as! String) ?? Data(), options: [])
            print(jsonFormater(data: json as Any).description)
            self.loadStatus()
        })
        manager?.defaultSocket.on("runtime", callback: { (data, ack) in
            
            let json = try? JSONSerialization.jsonObject(with: self.base64UrlDecode(data.first as! String) ?? Data(), options: []) as? [String:Any] ?? ["":""]
            if json!["code"] as! String == "000000" {
                let resData = jsonFormater(data: json!["data"] as Any)
                print(jsonFormater(data: json as Any).description)
                DispatchQueue.main.async {
                    if self.type == 0 {
                        if resData["status"].intValue == 3 {
                            self.loadStatus()
                        }else {
                            self.routeData(resData)
                        }
                    }else {                        
                        if resData["status"].intValue == 7 {
                            self.showTimer(3, "专场即将关闭", true)
                        }else {
                            self.loadStatus()
                        }
                    }
                }
            }
        })
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        var items:[String] = [String]()
        
        (UIApplication.shared.delegate as! AppDelegate).isplayData.forEach { (d) in
            items.append(d["name"].stringValue)
        }

        let menuView = TopMenu(navigationController: self.navigationController, containerView: self.navigationController!.view, title: BTTitle.title("\(self.type_name ?? "")"), items: items)
        menuView.cellTextLabelAlignment = .center
        if items.count > 0 {
            
            
            self.navigationItem.titleView = menuView
            
        }
        
        
        menuView.didTitleAtHandler = { (i:Bool) -> () in
            
//            if menuView.isShown == true {
//                menuView.hideMenu()
//                return
//            }
            
            showHUD()
            
            NetWorkRequest(.fairPlay()) { (res) -> (Void) in
                dismissHUD()
                if res["code"] as! String == "000000" {
                    (UIApplication.shared.delegate as! AppDelegate).isplayData = jsonFormater(data: res)["data"].arrayValue
                    
                    if (UIApplication.shared.delegate as! AppDelegate).isplayData.count <= 0 {
                        showMessage(message: "暂无专场")
                        return
                    }
                    var items:[String] = [String]()
                    
                    (UIApplication.shared.delegate as! AppDelegate).isplayData.forEach { (d) in
                        items.append(d["name"].stringValue)
                    }
                    menuView.updateItems(items)
                    menuView.show()
                }
            }
        }
        
            menuView.didSelectItemAtIndexHandler = {[weak self] (indexPath: Int) -> () in
            
                
                
            print("Did select item at index: \(indexPath)")
            
            var da = (UIApplication.shared.delegate as! AppDelegate).isplayData[indexPath]
            
            let vc = R.storyboard.home.guaListViewController()!.showType(t: da["trade_type"].intValue - 1)
            vc.fair_id = da["id"].stringValue
            vc.type_name = da["name"].stringValue
            vc.trade_type_text = da["trade_type_text"].stringValue
            vc.trade_date = da["trade_date"].stringValue
            vc.websocket = da["websocket_url"].stringValue
            
            self?.navigationController?.pushViewController(vc, animated: false)
            self?.manager?.defaultSocket.removeAllHandlers()
            self?.manager?.disconnect()
            
        }
        
        
        self.automaticallyAdjustsScrollViewInsets = false;
        self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
//        showTimer(11)
        
        view.addSubview(advancedManager)
        
        advancedManagerConfig()
        self.countView.frame = (self.navigationController?.view.bounds)!
        self.navigationController?.view.addSubview(self.countView)
        self.countView.isHidden = true
        
        loadStatus()
        reloadData()
//        showTimer(30,"专场即将开始")
//        return
        // Do any additional setup after loading the view.
        addRightBar()
    }
    func addRightBar() {
        let bar = UIBarButtonItem(image: R.image.nav_back(), style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.openMessage(_:)))
        self.navigationItem.leftBarButtonItem = bar
        
    }
    
    @objc func openMessage(_ bar : UIBarButtonItem) {
        if (UIApplication.shared.delegate as! AppDelegate).isplayData.count > 0 {
            self.navigationController?.popToRootViewController(animated: true)
        }else {
            self.navigationController?.popViewController(animated: true)
        }
    }
    func reloadData() -> Void {
        
        self.header?.xxLabel.text = self.type_name
        self.header?.label.text = "\(self.trade_date!) \(self.trade_type_text!)"
        
        
        let url = String(websocket.split(separator: "?").first!)
        
        let arr = websocket.split(separator: "?").last?.split(separator: "&")
        
        var token:String = ""
        
        arr?.forEach({ (d) in
            if String(d).contains("token") == true {
                token = String(d.split(separator: "=").last!)
            }
        })
        
        manager = SocketManager(socketURL: URL(string: url)!, config: [.log(false), .compress, .connectParams(["token":token,"transport":"polling","t":"MQ-tEbI","EIO":"3"]), .path("/ws")])
        
        
        manager?.defaultSocket.on(clientEvent: .connect) {data, ack in
            //            print("socket connected\(self.manager?.defaultSocket.sid ?? "")")
            print("-----初始化socket--->>>")
        }
        manager?.defaultSocket.on(clientEvent: .disconnect) {data, ack in
            //            print("socket disconnect\(self.manager?.defaultSocket.sid)")
        }
        manager?.defaultSocket.on(clientEvent: .error) {data, ack in
            //            print("socket error\(self.manager?.defaultSocket.sid)")
        }
        
        manager?.defaultSocket.on("message_type", callback: { (data, ack) in
            //            showMessage(message: jsonFormater(data: data).description)
        })
        
        manager?.defaultSocket.connect()
    }
    
    
    private func base64UrlDecode(_ value: String) -> Data? {
        var base64 = value
            .replacingOccurrences(of: "-", with: "+")
            .replacingOccurrences(of: "_", with: "/")
        let length = Double(base64.lengthOfBytes(using: String.Encoding.utf8))
        let requiredLength = 4 * ceil(length / 4.0)
        let paddingLength = requiredLength - length
        if paddingLength > 0 {
            let padding = "".padding(toLength: Int(paddingLength), withPad: "=", startingAt: 0)
            base64 += padding
        }
        return Data(base64Encoded: base64, options: .ignoreUnknownCharacters)
    }
    
    func routeData(_ resData:JSON) -> Void {
               
        self.header?.label11.text = "等待"
        
        self.countView.isHidden = true
        
        (self.vcs[0] as! Bottom1ViewController).statusS = resData["status"].intValue
        (self.vcs[1] as! Bottom1ViewController).statusS = resData["status"].intValue
        if self.vcs.count > 2 {
            (self.vcs[2] as! Bottom1ViewController).statusS = resData["status"].intValue
            (self.vcs[3] as! Bottom1ViewController).statusS = resData["status"].intValue
        }
        
        
        if resData["status"].intValue == 2 {
            if resData["section_break_ttl"].intValue <= 0 { return }
            self.showTimer(resData["section_break_ttl"].intValue, "交易即将开始", true)
        }else if resData["status"].intValue == 7 {
            (self.vcs[2] as! Bottom1ViewController).loadData()
            if resData["section_break_ttl"].intValue <= 0 {
                self.showAlert("专场即将结束")
                return }
            self.showTimer(resData["section_break_ttl"].intValue, "专场即将结束", true)
        }else if resData["status"].intValue == 10 {
            self.showAlert(self.status[resData["status"].intValue])
        }else if resData["status"].intValue == 9 {
            self.showAlert(self.status[resData["status"].intValue])
        }else if resData["status"].intValue == 4 {
            self.header?.label11.text = "等待"
            
            if resData["show_target_ttl_at"].intValue <= 0 { return }
            self.showTimer(resData["show_target_ttl_at"].intValue, "下一个交易节即将开启",true)
            
//            self.showAlert(self.status[resData["status"].intValue])
            
        }else if resData["status"].intValue == 5 {
            self.header?.label11.text = resData["section_number"].stringValue
            if resData["section_ttl"].intValue <= 0 { return }
            self.showTimer(resData["section_ttl"].intValue, "休息一下，离交易节开启还有",true)
            
        }else if resData["status"].intValue == 6 {
            
            (self.vcs[2] as! Bottom1ViewController).loadData()
            
            if resData["section_break_ttl"].intValue <= 0 { return }
            self.showTimer(resData["section_break_ttl"].intValue, "下一个交易节即将开启",true)
            
        }else if resData["status"].intValue == 9 {
            (self.vcs[2] as! Bottom1ViewController).loadData()
        }else if resData["status"].intValue == 1 {
            (self.vcs[2] as! Bottom1ViewController).loadData()
        }else {
            self.header?.label11.text = "等待"
        }
        
        if resData["status"].intValue != 3 {
            (self.vcs[0] as! Bottom1ViewController).clearData()
            (self.vcs[1] as! Bottom1ViewController).clearData()
//            (self.vcs[2] as! Bottom1ViewController).clearData()
            (self.vcs[3] as! Bottom1ViewController).clearData()
//            self.advancedManager.scrollToIndex(index: 0)
        }
        
        
        
        self.header?.label44.text = self.foamterDate(n: resData["server_time"].intValue)
        self.server_time = resData["server_time"].intValue
        
        self.DispatchTimer(timeInterval: 1) { (d) in
            self.server_time = (self.server_time ?? 0) + 1
            self.header?.label44.text = self.foamterDate(n: self.server_time!)
        }
    }
    
    func loadStatus() -> Void {
        alert?.dismiss(animated: false, completion: nil)
        if self.type == 0 {//竞价
            NetWorkRequest(.jingjiasession(id: fair_id)) { (res) -> (Void) in
                if res["code"] as! String == "000000" {
                    let resData = jsonFormater(data: res["data"] as Any)
                    
                    self.header?.label22.text = self.status[resData["status"].intValue]
                    if resData["status"].intValue == 3 {
                        (self.vcs[0] as! Bottom1ViewController).statusS = resData["status"].intValue
                        (self.vcs[1] as! Bottom1ViewController).statusS = resData["status"].intValue
                        if self.vcs.count > 2 {
                            (self.vcs[2] as! Bottom1ViewController).statusS = resData["status"].intValue
                            (self.vcs[3] as! Bottom1ViewController).statusS = resData["status"].intValue
                        }
                        self.header?.label11.text = resData["section_number"].stringValue
//                        self.header?.label22.text = self.status[resData["status"].intValue]
                        (self.vcs[0] as! Bottom1ViewController).targets = resData["targets"].arrayValue
                        (self.vcs[1] as! Bottom1ViewController).targets = resData["targets"].arrayValue

                        (UIApplication.shared.delegate as! AppDelegate).show_target_ttl_at = resData["show_target_ttl_at"].intValue
                        
                        if resData["section_id"].stringValue.isEmpty == false {
                            self.sessionId = resData["section_id"].stringValue
                            (self.vcs[0] as! Bottom1ViewController).sessionId(t: resData["section_id"].stringValue)
                            (self.vcs[1] as! Bottom1ViewController).sessionId(t: resData["section_id"].stringValue)
                            
                        }
                        
                        (self.vcs[2] as! Bottom1ViewController).loadData()
                        (self.vcs[3] as! Bottom1ViewController).loadData()
                        
                        self.section_ttl = resData["section_ttl"].intValue
                        
                        self.DispatchTimer2(timeInterval: 1, handler: { (d) in
                            self.section_ttl = self.section_ttl! - 1
                            if self.section_ttl! > 0 {
                                self.header?.label33.text = "\(self.section_ttl!)"
                                if self.section_ttl! <= 0 {
                                }
                            }else {
                                self.header?.label33.text = "--"
                            }
                            
                            (self.vcs[0] as! Bottom1ViewController).startTimer()
                            (self.vcs[1] as! Bottom1ViewController).startTimer()
                            
                        })
                        
                        self.header?.label44.text = self.foamterDate(n: resData["server_time"].intValue)
                        self.server_time = resData["server_time"].intValue
                        
                        self.DispatchTimer(timeInterval: 1) { (d) in
                            self.server_time = (self.server_time ?? 0) + 1
                            self.header?.label44.text = self.foamterDate(n: self.server_time!)
                        }
                        
                    }else {
                        
                        (self.vcs[0] as! Bottom1ViewController).clearData()
                        (self.vcs[1] as! Bottom1ViewController).clearData()
                    
                        (self.vcs[3] as! Bottom1ViewController).clearData()
                        
                        
                        self.routeData(resData)
                    }
                }
            }
            
        }else if self.type == 1 {
            self.header?.label1.text = "交易日期"
            self.header?.label3.text = "当前状态"
            self.header?.label2.isHidden = true
            self.header?.label22.isHidden = true
            self.header?.label4.isHidden = true
            self.header?.label44.isHidden = true
            NetWorkRequest(.guapaisession(id: fair_id)) { (res) -> (Void) in
                if res["code"] as! String == "000000" {
                    let resData = jsonFormater(data: res["data"] as Any)
                    (self.vcs[0] as! Bottom1ViewController).statusS = resData["status"].intValue
                    (self.vcs[1] as! Bottom1ViewController).statusS = resData["status"].intValue

                   
                    self.header?.label33.text = self.status2[resData["status"].intValue]
                    let df = DateFormatter.init()
                    df.dateFormat = "yyyy-MM-dd HH:mm:ss"
                    self.header?.label11.text = "\(df.string(from: Date(timeIntervalSince1970: TimeInterval(resData["open_at"].intValue)))) \n\(df.string(from: Date(timeIntervalSince1970: TimeInterval(resData["close_at"].intValue))))"

                    if resData["status"].intValue == 3 {
                        
                        (self.vcs[0] as! Bottom1ViewController).loadData()
                        (self.vcs[1] as! Bottom1ViewController).loadData()
                    }else if resData["status"].intValue == 2 {
                        (self.vcs[1] as! Bottom1ViewController).loadData()
                        if resData["break_time_ttl"].intValue <= 0 { return }
                        self.showTimer(resData["break_time_ttl"].intValue, "专场即将开始",true)
                    }else if resData["status"].intValue == 7 {
                        if resData["section_break_ttl"].intValue <= 0 {
                            self.showAlert("专场已结束")
                            return
                        }
                        self.showTimer(resData["section_break_ttl"].intValue, "专场即将结束",true)
                    }else if resData["status"].intValue == 4 {
                        self.showAlert("专场暂停中")
                    }else if resData["status"].intValue == 9 {
                        self.showAlert("该专场已不存在")
                    }else if resData["status"].intValue == 8 {
                        (self.vcs[0] as! Bottom1ViewController).clearData()
                    }
                    
                    
                }
            }
        }else {
            self.header?.label1.text = "交易日期"
            self.header?.label3.text = "当前状态"
            self.header?.label2.isHidden = true
            self.header?.label22.isHidden = true
            self.header?.label4.isHidden = true
            self.header?.label44.isHidden = true
            NetWorkRequest(.xieshangsession(id: fair_id)) { (res) -> (Void) in
                if res["code"] as! String == "000000" {
                    
                    
                    
                    let resData = jsonFormater(data: res["data"] as Any)
                    
                    
                    self.header?.label33.text = self.status2[resData["status"].intValue]
                    let df = DateFormatter.init()
                    df.dateFormat = "yyyy-MM-dd HH:mm:ss"
                    //                    self.header?.label11.backgroundColor = .red
                    self.header?.label11.text = "\(df.string(from: Date(timeIntervalSince1970: TimeInterval(resData["open_at"].intValue)))) \n\(df.string(from: Date(timeIntervalSince1970: TimeInterval(resData["close_at"].intValue))))"
                    
                    (self.vcs[0] as! Bottom1ViewController).statusS = resData["status"].intValue
                    (self.vcs[1] as! Bottom1ViewController).statusS = resData["status"].intValue
                    if resData["status"].intValue == 4 {
                        self.showAlert("专场暂停中")
                    }else if resData["status"].intValue == 2 {
                        if resData["break_time_ttl"].intValue <= 0 { return }
                        self.showTimer(resData["break_time_ttl"].intValue, "专场即将开始",true)
                    }else if resData["status"].intValue == 7 {
                        if resData["section_break_ttl"].intValue <= 0 {
                            self.showAlert("专场即将结束")
                            return
                        }
                        self.showTimer(resData["section_break_ttl"].intValue, "专场即将关闭",true)
                    }else if resData["status"].intValue == 3 {
                        (self.vcs[0] as! Bottom1ViewController).loadData()
                        (self.vcs[1] as! Bottom1ViewController).loadData()
                    }else if resData["status"].intValue == 9 {
                        self.showAlert("该专场已不存在")
                    }else if resData["status"].intValue == 8 {
                        (self.vcs[0] as! Bottom1ViewController).clearData()
                    }
                }
            }
        }
    }
    
    
    func showAlert(_ content:String) -> Void {
        alert?.dismiss(animated: false, completion: nil)
        self.countView.isHidden = true
        self.countView.clearTimer()
        alert = UIAlertController.showAlert(in: self, withTitle: "温馨提示", message: content, cancelButtonTitle: "确定", destructiveButtonTitle: nil, otherButtonTitles: nil, tap: {[weak self] (vc, ac, index) in
            self?.navigationController?.popViewController(animated: true)
        })
    }
    
    
    func showTimer(_ count:Int,_ title:String, _ isRequire:Bool) -> Void {
//        if (count)
        alert?.dismiss(animated: false, completion: nil)
        
        if count <= 0 {
            self.countView.isHidden = true
        }else {
            self.countView.isHidden = false
            self.countView.title = title
            self.countView.count = count
            self.countView.bl = {[weak self] (res) -> Void in
                if isRequire {
                    self?.loadStatus()
                    self?.countView.isHidden = true
                }
            }
            self.countView.updateCount()
        }
        
    }
    
    
    
    public func DispatchTimer2(timeInterval: Double, handler:@escaping (DispatchSourceTimer?)->())
    {
        timer2?.cancel()
        timer2 = DispatchSource.makeTimerSource(flags: [], queue: DispatchQueue.main)
        timer2?.schedule(deadline: .now(), repeating: timeInterval)
        timer2?.setEventHandler {
            DispatchQueue.main.async {
                handler(self.timer2)
            }
        }
        timer2?.resume()
    }
    
    
    public func DispatchTimer(timeInterval: Double, handler:@escaping (DispatchSourceTimer?)->())
    {
        timer?.cancel()
        timer = DispatchSource.makeTimerSource(flags: [], queue: DispatchQueue.main)
        timer?.schedule(deadline: .now(), repeating: timeInterval)
        timer?.setEventHandler {
            DispatchQueue.main.async {
                handler(self.timer)
            }
        }
        timer?.resume()
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    deinit {
        manager?.defaultSocket.removeAllHandlers()
        manager?.defaultSocket.disconnect()
    }
    
    func foamterDate(n:Int) -> String {
        let df = DateFormatter.init()
        df.dateFormat = "HH:mm:ss"
        return df.string(from: Date(timeIntervalSince1970: TimeInterval(n))).replacingOccurrences(of: " ", with: "\n")
    }
    
    /*
     // MARK: - Navigation
     
     // In a storyboard-based application, you will often want to do a little preparation before navigation
     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
     // Get the new view controller using segue.destinationViewController.
     // Pass the selected object to the new view controller.
     }
     */
    
}
extension GuaListViewController: LTAdvancedScrollViewDelegate {
    
    //MARK: 具体使用请参考以下
    private func advancedManagerConfig() {
        //MARK: 选中事件
        advancedManager.advancedDidSelectIndexHandle = {
            print("选中了 -> \($0)")
            if $0 < self.vcs.count-1 {
                if (self.type == 0 || self.type == 1) && $0 < 2 {
                    (self.vcs[$0] as! Bottom1ViewController).sessionId(t: self.sessionId)
                }else {
                    (self.vcs[$0] as! Bottom1ViewController).loadData()
                }
            }else {
                (self.vcs[$0] as! AmountDescViewController).loadData()
            }
        }
        
    }
    
    func glt_scrollViewOffsetY(_ offsetY: CGFloat) {
        //        print("offset --> ", offsetY)
    }
}
extension GuaListViewController {
    private func testLabel() -> GuaListHeaderView {
        return GuaListHeaderView(frame: CGRect(x: 0, y: 0, width: deviceWidth(), height: 221))
    }
}
